#ifndef DATA_CREATUREDEF_H
#define DATA_CREATUREDEF_H

#include <string>
#include "Common/Collections/Vector.h"

#include "Data/Objects/Detail.h"
#include "Data/Objects/Rotor.h"
#include "Data/Objects/Link.h"

namespace data {

	class CreatureDef {
	public:
		CreatureDef(
			std::string name,
			std::string description,
			std::string headId ) :
			m_name( name ),
			m_description( description ),
			m_headId( headId )
		{
			m_details = new cmn::Vector<Detail>();
			m_rotors = new cmn::Vector<Rotor>();
			m_links = new cmn::Vector<Link>();
		}

		CreatureDef( const CreatureDef& creature ) :
			m_name( creature.GetName() ),
			m_description( creature.GetDescription() ),
			m_headId( creature.GetHeadId() )
		{
			m_details = new cmn::Vector<Detail> ( creature.GetDetails() );
			m_rotors = new cmn::Vector<Rotor> ( creature.GetRotors() );
			m_links = new cmn::Vector<Link> ( creature.GetLinks() );
		}

		~CreatureDef() {
			delete m_links;
			delete m_rotors;
			delete m_details;
		}

		inline const std::string GetName() const { return m_name; }
		inline void SetName( std::string name ) { m_name = name; }

		inline const std::string GetDescription() const { return m_description; }
		inline void SetDescription( std::string description ) { m_description = description; }

		inline const std::string GetHeadId() const { return m_headId; }
		inline void SetHeadId( std::string headId ) { m_headId = headId; }

		inline void AddDetail( const Detail& detail )	{ m_details->Add( detail ); }
		inline void RemoveDetail( const Detail& detail ) { m_details->Remove( detail ); }
		inline const cmn::IIterable<Detail>* GetDetails() const { return m_details; }

		inline void AddRotor( const Rotor& rotor ) { m_rotors->Add( rotor ); }
		inline void RemoveRotor( const Rotor& rotor ) { m_rotors->Remove( rotor ); }
		inline const cmn::IIterable<Rotor>* GetRotors() const { return m_rotors; }

		inline void AddLink( const Link& link ) { m_links->Add( link ); }
		inline void RemoveLink( const Link& link ) { m_links->Remove( link ); }
		inline const cmn::IIterable<Link>* GetLinks() const { return m_links; }

	private:
		std::string m_name;
		std::string m_description;
		std::string m_headId;

		cmn::Vector<Detail>* m_details;
		cmn::Vector<Rotor>* m_rotors;
		cmn::Vector<Link>* m_links;
	};

	inline bool operator == ( const CreatureDef& a, const CreatureDef& b ) {
		if( a.GetName() != b.GetName() ) return false;
		if( a.GetDescription() != b.GetDescription() ) return false;
		if( a.GetHeadId() != b.GetHeadId() ) return false;

		if( !IterablesAreEqual( a.GetDetails(), b.GetDetails() ) ) return false;
		if( !IterablesAreEqual( a.GetRotors(), b.GetRotors() ) ) return false;
		if( !IterablesAreEqual( a.GetLinks(), b.GetLinks() ) ) return false;

		return true;
	}

	inline bool operator != ( const CreatureDef& a, const CreatureDef& b ) {
		return !( a == b );
	}

}
#endif
